local nya__lijian = fk.CreateSkill {

  name = "nya__lijian",

  tags = {  },

}



nya__lijian:addEffect("active", {
  name = "nya__lijian",
  anim_type = "offensive",
  min_card_num = 1,
  min_target_num = 2,
  prompt = function(self)
    if not player:hasSkill("nya__play", true) then
      return "#nya__lijian2"
    else
      return "#nya__lijian1"
    end
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(nya__lijian.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected < #Fk:currentRoom().alive_players - (player:hasSkill("nya__play", true) and 1 or 0) and
      not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected < #selected_cards + (player:hasSkill("nya__play", true) and 0 or 1)
  end,
  feasible = function(self, player, selected, selected_cards)
    return #selected > 1 and #selected == #selected_cards + (player:hasSkill("nya__play", true) and 0 or 1)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:throwCard(effect.cards, nya__lijian.name, player, player)
    local tos = table.simpleClone(effect.tos)
    room:sortPlayersByAction(tos, false)
    local targets = table.map(tos, function(id) return room:getPlayerById(id) end)
    for _, src in ipairs(targets) do
      if not src.dead then
        if table.contains(tos, src.id) then
          local dest = src:getNextAlive()
          while not table.contains(targets, dest) do
            dest = dest:getNextAlive()
          end
          if dest == src then break end
          table.removeOne(tos, src.id)
          room:useVirtualCard("duel", nil, src, dest, nya__lijian.name)
        else
          break
        end
      end
    end
  end,
})

return nya__lijian